<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="../../../assets/docs.css" rel="stylesheet" type="text/css" media="screen" />
<title>MooTools 1.3 Documentation - Types/Hash</title>
</head>

<body>
  <div class="doc">
    <div class="methods">
      <h4 class="menu-item"><a href="#Hash">Hash</a></h4>
      <div class="menu-item"><a href="#Hash:constructor">constructor</a></div>
      <div class="menu-item"><a href="#Hash:each">each</a></div>
      <div class="menu-item"><a href="#Hash:has">has</a></div>
      <div class="menu-item"><a href="#Hash:keyOf">keyOf</a></div>
      <div class="menu-item"><a href="#Hash:hasValue">hasValue</a></div>
      <div class="menu-item"><a href="#Hash:extend">extend</a></div>
      <div class="menu-item"><a href="#Hash:combine">combine</a></div>
      <div class="menu-item"><a href="#Hash:erase">erase</a></div>
      <div class="menu-item"><a href="#Hash:get">get</a></div>
      <div class="menu-item"><a href="#Hash:set">set</a></div>
      <div class="menu-item"><a href="#Hash:empty">empty</a></div>
      <div class="menu-item"><a href="#Hash:include">include</a></div>
      <div class="menu-item"><a href="#Hash:map">map</a></div>
      <div class="menu-item"><a href="#Hash:filter">filter</a></div>
      <div class="menu-item"><a href="#Hash:every">every</a></div>
      <div class="menu-item"><a href="#Hash:some">some</a></div>
      <div class="menu-item"><a href="#Hash:getClean">getClean</a></div>
      <div class="menu-item"><a href="#Hash:getKeys">getKeys</a></div>
      <div class="menu-item"><a href="#Hash:getValues">getValues</a></div>
      <div class="menu-item"><a href="#Hash:getLength">getLength</a></div>
      <div class="menu-item"><a href="#Hash:toQueryString">toQueryString</a></div>
      <h4 class="menu-item"><a href="#Utility">Utility</a></h4>
      <div class="menu-item"><a href="#H">H</a></div>
    </div>
    <div class="l-border r-border span-15 content">
      <h1 id="Hash"><a href="#Hash">Type: Hash</a></h1>
      <p class="description">A custom Object ({}) implementation which does not account for prototypes when setting, getting, or iterating.
        Useful because in JavaScript, we cannot use Object.prototype. Instead, we can use Hash.prototype!</p>
      <h3>Notes:</h3>
      <ul>
        <li>When possible, please use the <a href="../../../docs/core/Types/Object.html">Object</a> type!</li>
      </ul>
      <h2 id="Hash:constructor"><a href="#Hash:constructor">Hash Method: constructor</a></h2>
      <h3 class="description">Syntax:</h3>
      <pre class="javascript"><span class="kw2">var</span> myHash = <span class="kw2">new</span> Hash<span class="br0">(</span><span class="br0">[</span>object<span class="br0">]</span><span class="br0">)</span>;

</pre>
      <h3>Arguments:</h3>
      <ol>
        <li>object - (<em>mixed</em>) A hash or object to implement.</li>
      </ol>
      <h3>Returns:</h3>
      <ul>
        <li>(<em>hash</em>) A new Hash instance.</li>
      </ul>
      <h3>Examples:</h3>
      <pre class="javascript"><span class="kw2">var</span> myHash = <span class="kw2">new</span> Hash<span class="br0">(</span><span class="br0">{</span>
    aProperty: <span class="kw2">true</span>,
    aMethod: <span class="kw2">function</span><span class="br0">(</span><span class="br0">)</span><span class="br0">{</span>

        <span class="kw1">return</span> <span class="kw2">true</span>;
    <span class="br0">}</span>
<span class="br0">}</span><span class="br0">)</span>;
<span class="kw3">alert</span><span class="br0">(</span>myHash.<span class="me1">has</span><span class="br0">(</span><span class="st0">'aMethod'</span><span class="br0">)</span><span class="br0">)</span>; <span class="co1">//Returns true.</span>

</pre>
      <h2 id="Hash:each"><a href="#Hash:each">Hash Method: each</a></h2>
      <p class="description">Calls a function for each key-value pair in the object.</p>
      <h3>Syntax:</h3>
      <pre class="javascript">myHash.<span class="me1">each</span><span class="br0">(</span>fn<span class="br0">[</span>, bind<span class="br0">]</span><span class="br0">)</span>;

</pre>
      <h3>Arguments:</h3>
      <ol>
        <li>fn   - (<em>function</em>) The function which should be executed on each item in the Hash. This function is passed the item and its key in the Hash.</li>
        <li>bind - (<em>object</em>, optional) The object to use as 'this' in the function. For more information, see <a href="../../../docs/core/Types/Function.html#Function:bind">Function:bind</a>.</li>
      </ol>
      <h4>Argument: fn</h4>
      <h5>Syntax:</h5>
      <pre class="javascript">fn<span class="br0">(</span>value, key, hash<span class="br0">)</span>
</pre>
      <h5>Arguments:</h5>
      <ol>
        <li>value - (<em>mixed</em>) The current value in the hash.</li>
        <li>key   - (<em>string</em>) The current value's key in the hash.</li>
        <li>hash  - (<em>hash</em>) The actual hash.</li>
      </ol>
      <h3>Examples:</h3>
      <pre class="javascript"><span class="kw2">var</span> hash = <span class="kw2">new</span> Hash<span class="br0">(</span><span class="br0">{</span>first: <span class="st0">"Sunday"</span>, second: <span class="st0">"Monday"</span>, third: <span class="st0">"Tuesday"</span><span class="br0">}</span><span class="br0">)</span>;
hash.<span class="me1">each</span><span class="br0">(</span><span class="kw2">function</span><span class="br0">(</span>value, key<span class="br0">)</span><span class="br0">{</span>

    <span class="kw3">alert</span><span class="br0">(</span><span class="st0">"the "</span> + key + <span class="st0">" day of the week is "</span> + value<span class="br0">)</span>;
<span class="br0">}</span><span class="br0">)</span>; <span class="co1">//Alerts "the first day of the week is Sunday", "the second day of the week is Monday", etc.</span>
</pre>
      <h2 id="Hash:has"><a href="#Hash:has">Hash Method: has</a></h2>
      <p class="description">Tests for the presence of a specified key in the Hash.</p>
      <h3>Syntax:</h3>
      <pre class="javascript"><span class="kw2">var</span> inHash = myHash.<span class="me1">has</span><span class="br0">(</span><span class="kw1">item</span><span class="br0">)</span>;

</pre>
      <h3>Arguments:</h3>
      <ol>
        <li>key - (<em>string</em>) The key to search for in the Hash.</li>
      </ol>
      <h3>Returns:</h3>
      <ul>
        <li>(<em>boolean</em>) If the Hash has a defined value for the specified key, returns true. Otherwise, returns false.</li>
      </ul>
      <h3>Examples:</h3>
      <pre class="javascript"><span class="kw2">var</span> hash = <span class="kw2">new</span> Hash<span class="br0">(</span><span class="br0">{</span><span class="st0">'a'</span>: <span class="st0">'one'</span>, <span class="st0">'b'</span>: <span class="st0">'two'</span>, <span class="st0">'c'</span>: <span class="st0">'three'</span><span class="br0">}</span><span class="br0">)</span>;
hash.<span class="me1">has</span><span class="br0">(</span><span class="st0">'a'</span><span class="br0">)</span>; <span class="co1">//returns true</span>

hash.<span class="me1">has</span><span class="br0">(</span><span class="st0">'d'</span><span class="br0">)</span>; <span class="co1">//returns false</span>
</pre>
      <h3>Notes:</h3>
      <ul>
        <li>Testing for a Hash prototype will never return true. Only testing the actual properties of the Hash will return true.</li>
      </ul>
      <h2 id="Hash:keyOf"><a href="#Hash:keyOf">Hash Method: keyOf</a></h2>
      <p class="description">Returns the key of the specified value. Synonymous with <a href="../../../docs/core/Types/Array.html#Array:indexOf">Array:indexOf</a>.</p>
      <h3>Syntax:</h3>
      <pre class="javascript"><span class="kw2">var</span> key = myHash.<span class="me1">keyOf</span><span class="br0">(</span><span class="kw1">item</span><span class="br0">)</span>;

</pre>
      <h3>Arguments:</h3>
      <ol>
        <li>item - (<em>mixed</em>) The item to search for in the Hash.</li>
      </ol>
      <h3>Returns:</h3>
      <ul>
        <li>(<em>string</em>) If the Hash has a the specified item in it, returns the key of that item.</li>
        <li>(<em>boolean</em>) Otherwise, returns false.</li>
      </ul>
      <h3>Examples:</h3>
      <pre class="javascript"><span class="kw2">var</span> hash = <span class="kw2">new</span> Hash<span class="br0">(</span><span class="br0">{</span><span class="st0">'a'</span>: <span class="st0">'one'</span>, <span class="st0">'b'</span>: <span class="st0">'two'</span>, <span class="st0">'c'</span>: <span class="nu0">3</span><span class="br0">}</span><span class="br0">)</span>;
hash.<span class="me1">keyOf</span><span class="br0">(</span><span class="st0">'two'</span><span class="br0">)</span>; <span class="co1">//returns 'b'</span>

hash.<span class="me1">keyOf</span><span class="br0">(</span><span class="nu0">3</span><span class="br0">)</span>; <span class="co1">//returns 'c'</span>
hash.<span class="me1">keyOf</span><span class="br0">(</span><span class="st0">'four'</span><span class="br0">)</span> <span class="co1">//returns false</span>
</pre>
      <h3>Notes:</h3>
      <ul>
        <li>Testing for a Hash prototype will never return its key. Only the actual properties of the Hash will return their associated key.</li>
      </ul>
      <h2 id="Hash:hasValue"><a href="#Hash:hasValue">Hash Method: hasValue</a></h2>
      <p class="description">Tests for the presence of a specified value in the Hash.</p>
      <h3>Syntax:</h3>
      <pre class="javascript"><span class="kw2">var</span> inHash = myHash.<span class="me1">hasValue</span><span class="br0">(</span>value<span class="br0">)</span>;
</pre>
      <h3>Arguments:</h3>
      <ol>
        <li>value - (<em>mixed</em>) The value to search for in the Hash.</li>
      </ol>
      <h3>Returns:</h3>
      <ul>
        <li>(<em>boolean</em>) If the Hash has the passed in value in any of the keys, returns true. Otherwise, returns false.</li>
      </ul>
      <h3>Examples:</h3>
      <pre class="javascript"><span class="kw2">var</span> hash = <span class="kw2">new</span> Hash<span class="br0">(</span><span class="br0">{</span><span class="st0">'a'</span>: <span class="st0">'one'</span>, <span class="st0">'b'</span>: <span class="st0">'two'</span>, <span class="st0">'c'</span>: <span class="st0">'three'</span><span class="br0">}</span><span class="br0">)</span>;
hash.<span class="me1">hasValue</span><span class="br0">(</span><span class="st0">'one'</span><span class="br0">)</span>; <span class="co1">//returns true</span>

hash.<span class="me1">hasValue</span><span class="br0">(</span><span class="st0">'four'</span><span class="br0">)</span>; <span class="co1">//returns false</span>
</pre>
      <h2 id="Hash:extend"><a href="#Hash:extend">Hash Method: extend</a></h2>
      <p class="description">Extends this Hash with the key-value pairs from the object passed in.</p>
      <h3>Syntax:</h3>
      <pre class="javascript">myHash.<span class="me1">extend</span><span class="br0">(</span>properties<span class="br0">)</span>;
</pre>
      <h3>Arguments:</h3>
      <ol>
        <li>properties - (<em>object</em>) The object whose items should be extended into this Hash</li>
      </ol>
      <h3>Returns:</h3>
      <ul>
        <li>(<em>hash</em>) This Hash, extended.</li>
      </ul>
      <h3>Examples:</h3>
      <pre class="javascript"><span class="kw2">var</span> hash = <span class="kw2">new</span> Hash<span class="br0">(</span><span class="br0">{</span>

    <span class="st0">'name'</span>: <span class="st0">'John'</span>,
    <span class="st0">'lastName'</span>: <span class="st0">'Doe'</span>
<span class="br0">}</span><span class="br0">)</span>;
<span class="kw2">var</span> properties = <span class="br0">{</span>

    <span class="st0">'age'</span>: <span class="st0">'20'</span>,
    <span class="st0">'sex'</span>: <span class="st0">'male'</span>,
    <span class="st0">'lastName'</span>: <span class="st0">'Dorian'</span>
<span class="br0">}</span>;
hash.<span class="me1">extend</span><span class="br0">(</span>properties<span class="br0">)</span>;

<span class="co1">//hash now holds an object containing: { 'name': 'John', 'lastName': 'Dorian', 'age': '20', 'sex': 'male' };</span>
</pre>
      <h2 id="Hash:combine"><a href="#Hash:combine">Hash Method: combine</a></h2>
      <p class="description">Combines this Hash with the key-value pairs of the object passed in. Does not allow duplicates (old values are <strong>not</strong> overwritten by new ones) and is case and type sensitive.</p>
      <h3>Syntax:</h3>
      <pre class="javascript">myHash.<span class="me1">combine</span><span class="br0">(</span>properties<span class="br0">)</span>;

</pre>
      <h3>Arguments:</h3>
      <ol>
        <li>properties - (<em>object</em>) The object whose items should be combined into this Hash.</li>
      </ol>
      <h3>Returns:</h3>
      <ul>
        <li>(<em>hash</em>) This Hash, combined with the new key-value pairs.</li>
      </ul>
      <h3>Examples:</h3>
      <pre class="javascript"><span class="kw2">var</span> hash = <span class="kw2">new</span> Hash<span class="br0">(</span><span class="br0">{</span>
    <span class="st0">'name'</span>: <span class="st0">'John'</span>,
    <span class="st0">'lastName'</span>: <span class="st0">'Doe'</span>

<span class="br0">}</span><span class="br0">)</span>;
<span class="kw2">var</span> properties = <span class="br0">{</span>
    <span class="st0">'name'</span>: <span class="st0">'Jane'</span>
    <span class="st0">'age'</span>: <span class="st0">'20'</span>,
    <span class="st0">'sex'</span>: <span class="st0">'male'</span>,
    <span class="st0">'lastName'</span>: <span class="st0">'Dorian'</span>

<span class="br0">}</span>;
hash.<span class="me1">combine</span><span class="br0">(</span>properties<span class="br0">)</span>;
<span class="co1">//hash now holds an object containing: { 'name': 'John', 'lastName': 'Doe', 'age': '20', 'sex': 'male' };</span>

</pre>
      <h2 id="Hash:erase"><a href="#Hash:erase">Hash Method: erase</a></h2>
      <p class="description">Removes the specified key from the Hash.</p>
      <h3>Syntax:</h3>
      <pre class="javascript">myHash.<span class="me1">erase</span><span class="br0">(</span>key<span class="br0">)</span>;
</pre>
      <h3>Arguments:</h3>
      <ol>
        <li>key - (<em>string</em>) The key to search for in the Hash.</li>
      </ol>
      <h3>Returns:</h3>
      <ul>
        <li>(<em>hash</em>) This Hash with the specified key and its value removed.</li>
      </ul>
      <h3>Examples:</h3>
      <pre class="javascript"><span class="kw2">var</span> hash = <span class="kw2">new</span> Hash<span class="br0">(</span><span class="br0">{</span>

    <span class="st0">'name'</span>: <span class="st0">'John'</span>,
    <span class="st0">'lastName'</span>: <span class="st0">'Doe'</span>
<span class="br0">}</span><span class="br0">)</span>;
hash.<span class="me1">erase</span><span class="br0">(</span><span class="st0">'lastName'</span><span class="br0">)</span>;

<span class="co1">//hash now holds an object containing: { 'name': 'John' };</span>
</pre>
      <h2 id="Hash:get"><a href="#Hash:get">Hash Method: get</a></h2>
      <p class="description">Retrieves a value from the hash.</p>
      <h3>Syntax:</h3>
      <pre class="javascript">myHash.<span class="me1">get</span><span class="br0">(</span>key<span class="br0">)</span>;

</pre>
      <h3>Arguments:</h3>
      <ol>
        <li>key - (<em>string</em>) The key to retrieve in the Hash.</li>
      </ol>
      <h3>Returns:</h3>
      <ul>
        <li>(<em>mixed</em>) Returns the value that corresponds to the key if found.</li>
        <li>(<em>null</em>) null if the key doesn't exist.</li>
      </ul>
      <h3>Examples:</h3>
      <pre class="javascript"><span class="kw2">var</span> hash = <span class="kw2">new</span> Hash<span class="br0">(</span><span class="br0">{</span>

    <span class="st0">'name'</span>: <span class="st0">'John'</span>,
    <span class="st0">'lastName'</span>: <span class="st0">'Doe'</span>
<span class="br0">}</span><span class="br0">)</span>;
hash.<span class="me1">get</span><span class="br0">(</span><span class="st0">'name'</span><span class="br0">)</span>; <span class="co1">//returns 'John'</span>

</pre>
      <h2 id="Hash:set"><a href="#Hash:set">Hash Method: set</a></h2>
      <p class="description">Adds a key-value pair to the hash or replaces a previous value associated with the specified key.</p>
      <h3>Syntax:</h3>
      <pre class="javascript">myHash.<span class="me1">set</span><span class="br0">(</span>key, value<span class="br0">)</span>;

</pre>
      <h3>Arguments:</h3>
      <ol>
        <li>key   - (<em>string</em>) The key to insert or modify in the Hash.</li>
        <li>value - (<em>mixed</em>) The value to associate with the specified key in the Hash.</li>
      </ol>
      <h3>Returns:</h3>
      <ul>
        <li>(<em>hash</em>) This Hash with the specified key set to the specified value.</li>
      </ul>
      <h3>Examples:</h3>
      <pre class="javascript"><span class="kw2">var</span> hash = <span class="kw2">new</span> Hash<span class="br0">(</span><span class="br0">{</span>

    <span class="st0">'name'</span>: <span class="st0">'John'</span>,
    <span class="st0">'lastName'</span>: <span class="st0">'Doe'</span>
<span class="br0">}</span><span class="br0">)</span>;
hash.<span class="me1">set</span><span class="br0">(</span><span class="st0">'name'</span>, <span class="st0">'Michelle'</span><span class="br0">)</span>; <span class="co1">//hash.name is now 'Michelle'</span>

</pre>
      <h2 id="Hash:empty"><a href="#Hash:empty">Hash Method: empty</a></h2>
      <p class="description">Empties the hash.</p>
      <h3>Syntax:</h3>
      <pre class="javascript">myHash.<span class="me1">empty</span><span class="br0">(</span><span class="br0">)</span>;
</pre>
      <h3>Examples:</h3>
      <pre class="javascript"><span class="kw2">var</span> hash = <span class="kw2">new</span> Hash<span class="br0">(</span><span class="br0">{</span>
    <span class="st0">'name'</span>: <span class="st0">'John'</span>,
    <span class="st0">'lastName'</span>: <span class="st0">'Doe'</span>

<span class="br0">}</span><span class="br0">)</span>;
hash.<span class="me1">empty</span><span class="br0">(</span><span class="br0">)</span>;
<span class="co1">//hash now holds an empty object: {}</span>
</pre>
      <h2 id="Hash:include"><a href="#Hash:include">Hash Method: include</a></h2>
      <p class="description">Includes the specified key-value pair in the Hash if the key doesn't already exist.</p>
      <h3>Syntax:</h3>
      <pre class="javascript">myHash.<span class="me1">include</span><span class="br0">(</span>key, value<span class="br0">)</span>;
</pre>
      <h3>Arguments:</h3>
      <ol>
        <li>key   - (<em>string</em>) The key to insert into the Hash.</li>
        <li>value - (<em>mixed</em>) The value to associate with the specified key in the Hash.</li>
      </ol>
      <h3>Returns:</h3>
      <ul>
        <li>(<em>hash</em>) This Hash with the specified key included if it did not previously exist.</li>
      </ul>
      <h3>Examples:</h3>
      <pre class="javascript"><span class="kw2">var</span> hash = <span class="kw2">new</span> Hash<span class="br0">(</span><span class="br0">{</span>
    <span class="st0">'name'</span>: <span class="st0">'John'</span>,
    <span class="st0">'lastName'</span>: <span class="st0">'Doe'</span>

<span class="br0">}</span><span class="br0">)</span>;
hash.<span class="me1">include</span><span class="br0">(</span><span class="st0">'name'</span>, <span class="st0">'Michelle'</span><span class="br0">)</span>; <span class="co1">//hash is unchanged</span>
hash.<span class="me1">include</span><span class="br0">(</span><span class="st0">'age'</span>, <span class="nu0">25</span><span class="br0">)</span>; <span class="co1">//hash.age is now 25</span>

</pre>
      <h2 id="Hash:map"><a href="#Hash:map">Hash Method: map</a></h2>
      <p class="description">Creates a new map with the results of calling a provided function on every value in the map.</p>
      <h3>Syntax:</h3>
      <pre class="javascript"><span class="kw2">var</span> mappedHash = myHash.<span class="me1">map</span><span class="br0">(</span>fn<span class="br0">[</span>, bind<span class="br0">]</span><span class="br0">)</span>;

</pre>
      <h3>Arguments:</h3>
      <ol>
        <li>fn   - (<em>function</em>) The function to produce an element of the new Hash from an element of the current one.</li>
        <li>bind - (<em>object</em>, optional) The object to use as 'this' in the function. For more information see <a href="../../../docs/core/Types/Function.html#Function:bind">Function:bind</a>.</li>
      </ol>
      <h4>Argument: fn</h4>
      <h5>Syntax:</h5>
      <pre class="javascript">fn<span class="br0">(</span>value, key, hash<span class="br0">)</span>
</pre>
      <h5>Arguments:</h5>
      <ol>
        <li>value - (mixed) The current value in the hash.</li>
        <li>key   - (string) The current value's key in the hash.</li>
        <li>hash  - (hash) The actual hash.</li>
      </ol>
      <h3>Returns:</h3>
      <ul>
        <li>(<em>hash</em>) The new mapped hash.</li>
      </ul>
      <h3>Examples:</h3>
      <pre class="javascript"><span class="kw2">var</span> timesTwo = <span class="kw2">new</span> Hash<span class="br0">(</span><span class="br0">{</span>a: <span class="nu0">1</span>, b: <span class="nu0">2</span>, c: <span class="nu0">3</span><span class="br0">}</span><span class="br0">)</span>.<span class="me1">map</span><span class="br0">(</span><span class="kw2">function</span><span class="br0">(</span>value, key<span class="br0">)</span><span class="br0">{</span>

    <span class="kw1">return</span> value * <span class="nu0">2</span>;
<span class="br0">}</span><span class="br0">)</span>; <span class="co1">//timesTwo now holds an object containing: {a: 2, b: 4, c: 6};</span>
</pre>
      <h2 id="Hash:filter"><a href="#Hash:filter">Hash Method: filter</a></h2>
      <p class="description">Creates a new Hash with all of the elements of the Hash for which the provided filtering function returns true.</p>
      <h3>Syntax:</h3>
      <pre class="javascript"><span class="kw2">var</span> filteredHash = myHash.<span class="me1">filter</span><span class="br0">(</span>fn<span class="br0">[</span>, bind<span class="br0">]</span><span class="br0">)</span>;
</pre>
      <h3>Arguments:</h3>
      <ol>
        <li>fn   - (<em>function</em>) The function to test each element of the Hash. This function is passed the value and its key in the Hash.</li>
        <li>bind - (<em>object</em>, optional) The object to use as 'this' in the function. For more information see <a href="../../../docs/core/Types/Function.html#Function:bind">Function:bind</a>.</li>
      </ol>
      <h4>Argument: fn</h4>
      <h5>Syntax:</h5>
      <pre class="javascript">fn<span class="br0">(</span>value, key, hash<span class="br0">)</span>
</pre>
      <h5>Arguments:</h5>
      <ol>
        <li>value - (<em>mixed</em>) The current value in the hash.</li>
        <li>key   - (<em>string</em>) The current value's key in the hash.</li>
        <li>hash  - (<em>hash</em>) The actual hash.</li>
      </ol>
      <h3>Returns:</h3>
      <ul>
        <li>(<em>hash</em>) The new filtered hash.</li>
      </ul>
      <h3>Examples:</h3>
      <pre class="javascript"><span class="kw2">var</span> biggerThanTwenty = <span class="kw2">new</span> Hash<span class="br0">(</span><span class="br0">{</span>a: <span class="nu0">10</span>, b: <span class="nu0">20</span>, c: <span class="nu0">30</span><span class="br0">}</span><span class="br0">)</span>.<span class="me1">filter</span><span class="br0">(</span><span class="kw2">function</span><span class="br0">(</span>value, key<span class="br0">)</span><span class="br0">{</span>

    <span class="kw1">return</span> value &gt; <span class="nu0">20</span>;
<span class="br0">}</span><span class="br0">)</span>; <span class="co1">//biggerThanTwenty now holds an object containing: {c: 30}</span>
</pre>
      <h2 id="Hash:every"><a href="#Hash:every">Hash Method: every</a></h2>
      <p class="description">Returns true if every value in the object satisfies the provided testing function.</p>
      <h3>Syntax:</h3>
      <pre class="javascript"><span class="kw2">var</span> allPassed = myHash.<span class="me1">every</span><span class="br0">(</span>fn<span class="br0">[</span>, bind<span class="br0">]</span><span class="br0">)</span>;

</pre>
      <h3>Arguments:</h3>
      <ol>
        <li>fn   - (<em>function</em>) The function to test each element of the Hash. This function is passed the value and its key in the Hash.</li>
        <li>bind - (<em>object</em>, optional) The object to use as 'this' in the function. For more information see [Function:bind].</li>
      </ol>
      <h4>Argument: fn</h4>
      <h5>Syntax:</h5>
      <pre class="javascript">fn<span class="br0">(</span>value, key, hash<span class="br0">)</span>
</pre>
      <h5>Arguments:</h5>
      <ol>
        <li>value - (<em>mixed</em>) The current value in the hash.</li>
        <li>key   - (<em>string</em>) The current value's key in the hash.</li>
        <li>hash  - (<em>hash</em>) The actual hash.</li>
      </ol>
      <h3>Returns:</h3>
      <ul>
        <li>(<em>boolean</em>) If every value in the Hash satisfies the provided testing function, returns true. Otherwise, returns false.</li>
      </ul>
      <h3>Examples:</h3>
      <pre class="javascript"><span class="kw2">var</span> areAllBigEnough = <span class="br0">(</span><span class="br0">{</span>a: <span class="nu0">10</span>, b: <span class="nu0">4</span>, c: <span class="nu0">25</span>, d: <span class="nu0">100</span><span class="br0">}</span><span class="br0">)</span>.<span class="me1">every</span><span class="br0">(</span><span class="kw2">function</span><span class="br0">(</span>value, key<span class="br0">)</span><span class="br0">{</span>

    <span class="kw1">return</span> value &gt; <span class="nu0">20</span>;
<span class="br0">}</span><span class="br0">)</span>; <span class="co1">//areAllBigEnough = false</span>
</pre>
      <h2 id="Hash:some"><a href="#Hash:some">Hash Method: some</a></h2>
      <p class="description">Returns true if at least one value in the object satisfies the provided testing function.</p>
      <h3>Syntax:</h3>
      <pre class="javascript"><span class="kw2">var</span> anyPassed = myHash.<span class="me1">any</span><span class="br0">(</span>fn<span class="br0">[</span>, bind<span class="br0">]</span><span class="br0">)</span>;

</pre>
      <h3>Arguments:</h3>
      <ol>
        <li>fn   - (<em>function</em>) The function to test each element of the Hash. This function is passed the value and its key in the Hash.</li>
        <li>bind - (<em>object</em>, optional) The object to use as 'this' in the function. For more information see <a href="../../../docs/core/Types/Function.html#Function:bind">Function:bind</a>.</li>
      </ol>
      <h4>Argument: fn</h4>
      <h5>Syntax:</h5>
      <pre class="javascript">fn<span class="br0">(</span>value, key, hash<span class="br0">)</span>
</pre>
      <h5>Arguments:</h5>
      <ol>
        <li>value - (<em>mixed</em>) The current value in the hash.</li>
        <li>key   - (<em>string</em>) The current value's key in the hash.</li>
        <li>hash  - (<em>hash</em>) The actual hash.</li>
      </ol>
      <h3>Returns:</h3>
      <ul>
        <li>(<em>boolean</em>) If any value in the Hash satisfies the provided testing function, returns true. Otherwise, returns false.</li>
      </ul>
      <h3>Examples:</h3>
      <pre class="javascript"><span class="kw2">var</span> areAnyBigEnough = <span class="br0">(</span><span class="br0">{</span>a: <span class="nu0">10</span>, b: <span class="nu0">4</span>, c: <span class="nu0">25</span>, d: <span class="nu0">100</span><span class="br0">}</span><span class="br0">)</span>.<span class="me1">some</span><span class="br0">(</span><span class="kw2">function</span><span class="br0">(</span>value, key<span class="br0">)</span><span class="br0">{</span>

    <span class="kw1">return</span> value &gt; <span class="nu0">20</span>;
<span class="br0">}</span><span class="br0">)</span>; <span class="co1">//isAnyBigEnough = true</span>
</pre>
      <h2 id="Hash:getClean"><a href="#Hash:getClean">Hash Method: getClean</a></h2>
      <p class="description">Returns a a clean object from an Hash.</p>
      <h3>Syntax:</h3>
      <pre class="javascript">myHash.<span class="me1">getClean</span><span class="br0">(</span><span class="br0">)</span>;
</pre>
      <h3>Returns:</h3>
      <ul>
        <li>(<em>object</em>) a clean object</li>
      </ul>
      <h3>Examples:</h3>
      <pre class="javascript"><span class="kw2">var</span> hash = <span class="kw2">new</span> Hash<span class="br0">(</span><span class="br0">{</span>

    <span class="st0">'name'</span>: <span class="st0">'John'</span>,
    <span class="st0">'lastName'</span>: <span class="st0">'Doe'</span>
<span class="br0">}</span><span class="br0">)</span>;
hash = hash.<span class="me1">getClean</span><span class="br0">(</span><span class="br0">)</span>; <span class="co1">// hash doesnt contain Hash prototypes anymore</span>

hash.<span class="me1">each</span><span class="br0">(</span><span class="br0">)</span> <span class="co1">//error!</span>
</pre>
      <h2 id="Hash:getKeys"><a href="#Hash:getKeys">Hash Method: getKeys</a></h2>
      <p class="description">Returns an array containing all the keys, in the same order as the values returned by <a href="#Hash:getValues">Hash:getValues</a>.</p>
      <h3>Syntax:</h3>
      <pre class="javascript"><span class="kw2">var</span> keys = myHash.<span class="me1">getKeys</span><span class="br0">(</span><span class="br0">)</span>;
</pre>
      <h3>Returns:</h3>
      <ul>
        <li>(<em>array</em>) An array containing all the keys of the hash.</li>
      </ul>
      <h2 id="Hash:getValues"><a href="#Hash:getValues">Hash Method: getValues</a></h2>
      <p class="description">Returns an array containing all the values, in the same order as the keys returned by <a href="#Hash:getKeys">Hash:getKeys</a>.</p>
      <h3>Syntax:</h3>
      <pre class="javascript"><span class="kw2">var</span> values = myHash.<span class="me1">getValues</span><span class="br0">(</span><span class="br0">)</span>;

</pre>
      <h3>Returns:</h3>
      <ul>
        <li>(<em>array</em>) An array containing all the values of the hash.</li>
      </ul>
      <h2 id="Hash:getLength"><a href="#Hash:getLength">Hash Method: getLength</a></h2>
      <p class="description">Returns the number of keys in the Hash.</p>
      <h3>Syntax:</h3>
      <pre class="javascript"><span class="kw2">var</span> length = myHash.<span class="me1">getLength</span><span class="br0">(</span><span class="br0">)</span>;
</pre>
      <h3>Returns:</h3>
      <ul>
        <li>(<em>number</em>) The length of the Hash.</li>
      </ul>
      <h3>Examples:</h3>
      <pre class="javascript"><span class="kw2">var</span> hash = <span class="kw2">new</span> Hash<span class="br0">(</span><span class="br0">{</span>
    <span class="st0">'name'</span>: <span class="st0">'John'</span>,
    <span class="st0">'lastName'</span>: <span class="st0">'Doe'</span>

<span class="br0">}</span><span class="br0">)</span>;
hash.<span class="me1">getLength</span><span class="br0">(</span><span class="br0">)</span>; <span class="co1">// returns 2</span>
</pre>
      <h2 id="Hash:toQueryString"><a href="#Hash:toQueryString">Hash Method: toQueryString</a></h2>
      <p class="description">Generates a query string from key/value pairs in an object and URI encodes the values.</p>
      <h3>Syntax:</h3>
      <pre class="javascript"><span class="kw2">var</span> queryString = myHash.<span class="me1">toQueryString</span><span class="br0">(</span><span class="br0">)</span>;
</pre>
      <h3>Arguments:</h3>
      <ol>
        <li>source - (<em>object</em>) The object to generate the query string from.</li>
      </ol>
      <h3>Returns:</h3>
      <ul>
        <li>(<em>string</em>) The query string.</li>
      </ul>
      <h3>Examples:</h3>
      <h4>Using Hash generic:</h4>
      <pre class="javascript">Hash.<span class="me1">toQueryString</span><span class="br0">(</span><span class="br0">{</span>apple: <span class="st0">"red"</span>, lemon: <span class="st0">"yellow"</span><span class="br0">}</span><span class="br0">)</span>; <span class="co1">//returns "apple=red&amp;lemon=yellow"</span>

</pre>
      <h4>Using Hash instance:</h4>
      <pre class="javascript"><span class="kw2">var</span> myHash = <span class="kw2">new</span> Hash<span class="br0">(</span><span class="br0">{</span>apple: <span class="st0">"red"</span>, lemon: <span class="st0">"yellow"</span><span class="br0">}</span><span class="br0">)</span>;
myHash.<span class="me1">toQueryString</span><span class="br0">(</span><span class="br0">)</span>; <span class="co1">//returns "apple=red&amp;lemon=yellow"</span>

</pre>
      <h1 id="Utility"><a href="#Utility">Utility Functions</a></h1>
      <h2 id="H" class="description"><a href="#H">Function: $H</a></h2>
      <p class="description">Shortcut for the new <a href="#Hash">Hash</a>.</p>
      <h3>See Also:</h3>
      <ul>
        <li><a href="#Hash">Hash</a></li>
      </ul>
    </div>
  </div>
<script type="text/javascript" src="../../../assets/mootools-core-1.3.js"></script>
<script type="text/javascript" src="../../../assets/mootools-more-smoothscroll.js"></script>
<script type="text/javascript" src="../../../assets/doc-assist.js"></script>
</body>
</html>
